<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
    <head>
        <%@include file="/WEB-INF/jspf/head.jspf" %>
        <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/portal_1/css/register.css"/> 
        <script type="text/javascript" src="<%=request.getContextPath() %>/portal_1/js/jquery/jquery-1.5.min.js"></script>
    </head>
    <body>
        <div id="html">
            <%@include file="/WEB-INF/jspf/header.jspf" %>
            <div id="register">
                <div class="left">
                    <h2>用户注册</h2>
                    <form action="register"  id="myform" method="post">
			 			<p>
			 			<label>姓名：</label><input type="text" name="realName"  id="name" onblur="checkname(this);"  maxlength=10/><font color="red"><span id="namespan"></span></font>
			 			</p>
			 			<p>
			 			<label>用户名：</label><input type="text"  name="loginName"  id="loginName" maxlength=30 onblur="checkloginid(this);"/><font color="red"><span id="loginidspan"></span></font>
			 			</p>
			 			<p>
			 			<label>初始密码：</label><input id="initpwd" type="password" name="passWord" onblur="checkpwd(this);" maxlength=30/><font color="red"><span id="pwdspan"></span></font>
			 			</p>
			 			<p>
			 			<label>确认密码：</label><input type="password" name="PWD2" onblur="checkpwd2(this);" maxlength=30/><font color="red"><span id="pwd2span"></span></font>
			 			</p>
			 			<p>
			 			<label>会员类型：</label><select name="type"><option value="1" selected="selected">普通会员</option><option value="2">vip会员</option></select>
			 			</p>
			 			<p>
			 			<label>邮箱：</label><input type="text" name="email" onblur="checkEmail(this);" maxlength=30/><font color="red"><span id="emailspan"></span></font>
			 			</p>
			 				
			 			<p>
			 			
			 			<label>验证码：</label><input id="yzm" type="text" name="yzm"  maxlength=10/><img style='cursor:pointer' src='/cms/validatecode.jpg' onclick="changeyz();" id="yz"/><font color="red"><span id="yzspan"></span></font>
			 			</p>
			 			<p>
			 				<input type="button"  class="button" value="注册" onclick="validate();"/>
 						</p>
 				</form>
                </div>
                <div class="right">
                    <h2>用户须知</h2>
                    <p>由于本网站涉及房屋买卖，所以注册用户必须以真实身份注册。</p>
                </div>
                <br class="clear" />
            </div>
            <%@include file="/WEB-INF/jspf/footer.jspf" %>
        </div>
        <script type="text/javascript">
 	var namespan=document.getElementById("namespan");
 	var loginidspan=document.getElementById("loginidspan");
 	var pwdspan=document.getElementById("pwdspan");
 	var pwd2span=document.getElementById("pwd2span");
 	var yz=document.getElementById("yzspan");
 	var emailspan=document.getElementById("emailspan");
 	function checkname(obj){ 	
 	if(obj.value.length<=0){	
 	namespan.innerHTML="请输入姓名";
 	}else{
 	namespan.innerHTML="";
 	} 	
 	}
 	
 	function checkloginid(obj){ 	
 	if(obj.value.length<=0){	
 	loginidspan.innerHTML="请输入用户名";
 	
 	}else{
	
 	 $.ajax({
     		type:"post",
            url:"checkName",
            dataType:"text",
            data:"loginID="+obj.value, 
    
	     success: function(msg){       
	      		if(msg==2){
	      		loginidspan.innerHTML="该用户名已被注册";
	      		}else if(msg==1){
	      		loginidspan.innerHTML="";
	      		}
	       }   
		});  	
 	} 	
 	}
 	
 	
 	
 	
 	function checkpwd(obj){ 	
 	if(obj.value.length<=0){	
 	pwdspan.innerHTML="请输入密码";
 	}else{
 	pwdspan.innerHTML="";
 	} 	
 	}
 	function checkpwd2(obj){ 
 	var initpwd=document.getElementById("initpwd").value;	
 	if(obj.value.length<=0){	
 	pwd2span.innerHTML="请确认密码";
 	}else{
 	if(initpwd==obj.value){
 	pwd2span.innerHTML="";
 	}else{
 	pwd2span.innerHTML="两次密码不一样";
 	}
 	
 	} 	
 	}
 	
 	function checkyz(obj){
 	if(obj.value.length<=0){	
 	yzspan.innerHTML="请输入验证码";
 	}else{
 	
 	
 	 $.ajax({
     		type:"post",
            url:"checkYZM",
            dataType:"text",
            data:"yzm="+obj.value, 
    
	     success: function(msg){       
	      		if(msg==2){
	      		yzspan.innerHTML="验证码错误";
	      		}else if(msg==1){
	      		yzspan.innerHTML="";
	      		}
	       }   
		});  	
 	
 	
 	} 	
 	}
 	
 	
 	 	function validate(){
 	var f=document.getElementById("myform");
 	
 	if(document.getElementById("yzm").value.length<=0){	
 	yzspan.innerHTML="请输入验证码";	
 	}else{
 	
 	if(yzspan.innerHTML=="验证码错误"){
 	return;
 	}else{
 		if(document.getElementById("loginName").value.length<=0){
 	loginidspan.innerHTML="请输入用户名";
 	}else if(loginidspan.innerHTML=="该用户名已被注册"){
 	return;
 	}
 	else if(document.getElementById("initpwd").value.length<=0){
 	pwdspan.innerHTML="请输入密码";
 	}else if(document.getElementById("name").value.length<=0){
 	namespan.innerHTML="请输入姓名";
 	}else if(emailspan.innerHTML=="请输入正确的邮箱格式"){
 	return;
 	}
 	
 	
 	else{
 	
 	
 	f.submit();
 	}
 	}
 
 	}
 	}
 	
 	
 	function checkEmail(obj){
 	
 	if(obj.value.length>0){
 		  var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
 		  if(!myreg.test(obj.value)){		  
 		  emailspan.innerHTML="请输入正确的邮箱格式";
 		  }else{
 		   emailspan.innerHTML="";
 		  }
 	}if(obj.value.length<=0){
 	 emailspan.innerHTML="";
 	}
 	}
 	
 </script>
    </body>
</html>
